package com.example.basic.zonetime;

import java.time.DayOfWeek;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;

public class ZoneDateTimeTest {

    public static void main(String[] args) {

//        String year = "2021";
//        String month = "11";
//
//        ZonedDateTime startOfWeek = ZonedDateTime.
//                of(2021,11,1,14,36,36,666,ZoneId.systemDefault())
//                .truncatedTo(ChronoUnit.HOURS);
//                .withZoneSameInstant(ZoneId.of("UTC"));

//        System.out.println(startOfWeek.getZone().getId());
//
//        ZonedDateTime startOfWeek1 = ZonedDateTime.
//                of(2021,11,1,6,36,36,666,ZoneId.systemDefault())
//                .withZoneSameInstant(ZoneId.of("UTC"));
//
//        ZonedDateTime startOfWeek2 = ZonedDateTime.
//                of(2021,11,1,14,36,36,666,ZoneId.systemDefault())
//                .truncatedTo(ChronoUnit.HOURS)
//                .withZoneSameLocal(ZoneId.of("UTC"));
//
//        ZonedDateTime startOfWeek3 = ZonedDateTime.
//                of(2021,11,1,14,36,36,666,ZoneId.systemDefault())
//                .withZoneSameLocal(ZoneId.of("UTC"));

//        ZonedDateTime startOfWeek = ZonedDateTime.now(ZoneId.systemDefault())
//                .truncatedTo(ChronoUnit.DAYS)
//                .withZoneSameInstant(ZoneId.of("UTC"));

        // Add 7 days to get the end of the week
//        ZonedDateTime endOfWeek = startOfWeek.plusMonths(1L).minusDays(1);
//
//        System.out.println(startOfWeek);
//        System.out.println(startOfWeek1);
//        System.out.println(startOfWeek2);
//        System.out.println(startOfWeek3);
//        System.out.println(endOfWeek);


//        ZonedDateTime startOfWeek = ZonedDateTime.
//                of(2021,11,1,15,36,36,800,ZoneId.systemDefault())
//                .withZoneSameLocal(ZoneId.of("Asia/Shanghai"));
//
//        System.out.println(startOfWeek.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
//
//        ZonedDateTime startOfWeek1 = ZonedDateTime.
//                of(2021,11,1,0,0,0,0,ZoneId.systemDefault());
//        ZonedDateTime startOfWeek = ZonedDateTime.now(tzId)
//                .with(TemporalAdjusters.previousOrSame(DayOfWeek.SUNDAY))
//                .truncatedTo(ChronoUnit.MONTHS)
//                .withZoneSameInstant(ZoneId.of("UTC"));

        // Add 7 days to get the end of the week
//        ZonedDateTime endOfWeek = startOfWeek.plusDays(0);
//        ZonedDateTime endOfWeek = startOfWeek.plusMonths(1L).minusMinutes(1L);
//        System.out.println(startOfWeek);
//        System.out.println(startOfWeek1);
//        System.out.println(endOfWeek);

//        ZonedDateTime parse = ZonedDateTime.parse("2021-11-17T06:28:27.408177Z");
//        System.out.println(parse);

        LocalDateTime localDateTime = LocalDateTime.parse("2021-11-17T06:28:27.408177Z");
        System.out.println(localDateTime.getYear() + " " + localDateTime.getMonthValue() + " " + localDateTime.getDayOfMonth() + " " + localDateTime.getHour() + " " + localDateTime.getMinute());

//        ZonedDateTime startOfWeek2 = ZonedDateTime.
//                of(localDateTime.getYear(),localDateTime.getMonthValue(),localDateTime.getDayOfMonth(),localDateTime.getHour(),localDateTime.getMinute(),0,0,ZoneId.systemDefault());
//
//        System.out.println(startOfWeek2);
    }

}
